<template>
  <section class="container">
    <div id="wrapper">
      <div class="header">
        <div class="header_logo">
          <a href="/">我的藏书阁</a>
        </div>
      </div>
      <AppLogo></AppLogo>
      <div class="box_con">
        <div class="con_top">
          <a href="/">我的藏书阁</a> &gt;
          <a href="/xclass/1/1.html">玄幻奇幻</a>
          &gt; {{ name }}最新章节列表
        </div>
        <div id="maininfo">
          <div id="info">
            <h1>{{ name }}</h1>
            <p>作&nbsp;&nbsp;&nbsp;&nbsp;者：{{ author }}</p>
            <p>状&nbsp;&nbsp;&nbsp;&nbsp;态：连载中,
              <a rel="nofollow" href="javascript:;" onclick="addBookCase(76449);">加入书架</a>,
              <a href="#footer">直达底部</a>
            </p>
            <p>最近更新时间：{{endTime}}</p>
            <p>最新章节：
              <a href target="_blank">{{ end }}</a>
            </p>
          </div>
          <div id="intro">
            <p>{{ desc }}</p>
            <p>各位书友要是觉得《{{ name }}》还不错的话请不要忘记向您QQ群和微博里的朋友推荐哦！</p>
          </div>
        </div>
        <div id="sidebar">
          <div id="fmimg">
            <img
              :src="img_url"
              width="120"
              height="150"
              onerror="this.src='/images/nocover.jpg'"
            >
          </div>
        </div>
        <div id="listtj">推荐阅读：
          <a href="/76_76450/">科技禁区</a>
          <a href="/76_76451/">最强渡灵人</a>
          <a href="/76_76452/">悍唐</a>
          <a href="/76_76453/">我家后院是明朝</a>
          <a href="/76_76454/">未来宠物店</a>
          <a href="/76_76448/">神级散财系统</a>
          <a href="/76_76447/">朕乃玉皇大帝</a>
          <a href="/76_76446/">文娱江湖</a>
          <a href="/76_76445/">西游直播间</a>
          <a href="/76_76444/">老衲要还俗</a>
        </div>
      </div>
      <div class="box_con">
        <div id="list">
          <dl>
            <dt>《{{ name }}》正文</dt>

            <!-- 循环开始 -->
            <dd v-for="(item, index) in chapter" :key="index">
              <a :href="item.url">{{ item.name }}</a>
            </dd>
            <!-- 循环结束 -->
          </dl>
        </div>
      </div>
      <div id="footer" name="footer">
        <div class="footer_link">新书推荐：
          <a href="/1_1203/" title="凡人修仙之仙界篇">凡人修仙之仙界篇</a>
          <a href="/3_3197/" title="飞剑问道">飞剑问道</a>
          <a href="/9_9208/" title="伏天氏">伏天氏</a>
          <a href="/20_20331/" title="万古神帝">万古神帝</a>
          <a href="/34_34822/" title="三寸人间">三寸人间</a>
          <a href="/66_66414/" title="龙王传说">龙王传说</a>
          <a href="/68_68470/" title="斗战狂潮">斗战狂潮</a>
          <a href="/74_74821/" title="圣墟">圣墟</a>
          <a href="/77_77268/" title="剑来">剑来</a>
          <a href="/77_77473/" title="牧神记">牧神记</a>
          <a href="/78_78113/" title="汉乡">汉乡</a>
          <a href="/78_78201/" title="大王饶命">大王饶命</a>
        </div>
        <div class="footer_cont">
          <p>《{{ name }}》情节跌宕起伏、扣人心弦，是一本情节与文笔俱佳的小说，我的藏书阁转载收集{{ name }}最新章节。</p>
          <p>本站所有小说为转载作品，所有章节均由网友上传，转载至本站只是为了宣传本书让更多读者欣赏。</p>
          <p>Copyright © 2019 我的藏书阁 All Rights Reserved.</p>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
import AppLogo from "~/components/AppLogo.vue";
import axios from "axios";

export default {
  components: {
    AppLogo
  },
  data() {
    return {
      name: "", //书名
      author: "", //作者
      desc: "", //描述
      label: "", //频道
      img_url: "",//封面图片
      chapter: null,
      end: "",
      endTime: ""
    };
  },
  created() {
    var data = {
          book_chapter_id: this.$route.query.book_chapter_id,
          book_id: this.$route.query.book_id,
          book_source_id: this.$route.query.book_source_id
        }
    axios
      .get("https://uniontest.bookapi.cn/union/book/cover?skipAuth=true", {
        params: data
      })
      .then(response => {
          this.name = response.data.data.name, //书名
          this.author = response.data.data.author, //作者
          this.desc = response.data.data.desc, //描述
          this.label = response.data.data.label; //频道
          this.img_url = response.data.data.img_url //图片地址
      })
      .catch(function(err) {
        console.log(err);
      });
    axios
      .get("https://uniontest.bookapi.cn/union/book/chapter?skipAuth=true", {
        params:data
      })
      .then(response => {
        this.chapter = response.data.data.chapters;
        this.end =
          response.data.data.chapters[
            response.data.data.chapters.length - 1
          ].name;
          var d=new Date(response.data.data.chapters[response.data.data.chapters.length-1].update_time);
        this.endTime =this.formatDate(d)
      })
      .catch(function(err) {
        console.log(err);
      });
  },
  methods: {
    formatDate(now) { 
      var year=now.getFullYear(); 
      var month=now.getMonth()+1; 
      var date=now.getDate(); 
      var hour=now.getHours(); 
      var minute=now.getMinutes(); 
      var second=now.getSeconds(); 
      return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; 
    } 
    
  }
};
</script>

<style scoped>
</style>

